This helps prevent accidents with GTK_PATH.
}
}
-static void
-check_mixed_deps (void)
+/* Return TRUE if module_to_check causes version conflicts.
+ * If module_to_check is NULL, check the main module.
+ */
+gboolean
+_gtk_module_has_mixed_deps (GModule *module_to_check)
{
GModule *module;
gpointer func;
+ gboolean result;
- module = g_module_open (NULL, 0);
+ if (!module_to_check)
+ module = g_module_open (NULL, 0);
+ else
+ module = module_to_check;
if (g_module_symbol (module, "gtk_progress_get_type", &func))
- {
- g_error ("GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported");
- }
+ result = TRUE;
+ else
+ result = FALSE;
+
+ if (!module_to_check)
+ g_module_close (module);
- g_module_close (module);
+ return result;
}
static void
pre_initialized = TRUE;
- check_mixed_deps ();
+ if (_gtk_module_has_mixed_deps (NULL))
+ g_error ("GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported");
gdk_pre_parse_libgtk_only ();
gdk_event_handler_set ((GdkEventFunc)gtk_main_do_event, NULL, NULL);
-
+
#ifdef G_ENABLE_DEBUG
env_string = g_getenv ("GTK_DEBUG");
if (env_string != NULL)
gchar *_gtk_get_lc_ctype (void);
+gboolean _gtk_module_has_mixed_deps (GModule *module);
+
G_END_DECLS
#endif /* __GTK_MAIN_PRIVATE_H__ */
#include "gtksettings.h"
#include "gtkdebug.h"
#include "gtkprivate.h" /* GTK_LIBDIR */
-#include "gtkintl.h"
+#include "gtkmainprivate.h"
+#include "gtkintl.h"
#include <gmodule.h>
}
module = g_module_open (module_name, G_MODULE_BIND_LOCAL | G_MODULE_BIND_LAZY);
- g_free(module_name);
+
+ if (_gtk_module_has_mixed_deps (module))
+ {
+ g_warning ("GTK+ module %s cannot be loaded.\n"
+ "GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported.", module_name);
+ g_module_close (module);
+ module = NULL;
+ }
+
+ g_free (module_name);
return module;
}
for (l = gtk_modules; l; l = l->next)
{
info = l->data;
- if (g_slist_find_custom (info->names, name,
+ if (g_slist_find_custom (info->names, name,
(GCompareFunc)strcmp))
{
info->ref_count++;
}
}
- if (!success)
+ if (!success)
{
module = find_module (name);
}
}
else
- g_message ("Failed to load module \"%s\": %s", name, g_module_error ());
-
+ {
+ const gchar *error = g_module_error ();
+
+ g_message ("Failed to load module \"%s\"%s%s",
+ name, error ? ": " : "", error ? error : "");
+ }
+
return module_list;
}